<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/jsp/inc/header.jsp" %>
<c:set var="title" value="黄页"/>
<c:set var="rootpath" value="${CONTEXT_PATH}/admin/yellow/yellowPage/"/>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<link href="${STATIC_HOST}/css/ligerui.css" rel="stylesheet" type="text/css"/>
	<link href="${STATIC_HOST}/css/common.css" rel="stylesheet" type="text/css" />

	<script src="${STATIC_HOST}/js/jquery/jquery-1.7.2.min.js" type="text/javascript" ></script>    <!--兼容性问题--->
	<script src="${STATIC_HOST}/js/ligerUI/ligerui.min.js" type="text/javascript"></script>
	<script src="${STATIC_HOST}/js/json/json2.js" type="text/javascript"></script>
	<script src="${STATIC_HOST}/js/LG.js" type="text/javascript"></script>
	<script src="${STATIC_HOST}/js/ckeditor/ckeditor.js" type="text/javascript"></script>

	<title>${yellowPage.id==0 ? '新增' : '修改'}${title}</title>
</head>
<body>
<form:form commandName="yellowPage" class="l-form" id="mainform" name="mainform" method="post" action="${rootpath}/save.do">
<div class="pnl J_LigerForm">
	<div class="pnl-hd">
		<div class="hd-tit"><span>当前位置: 宇宙CMS&gt; <c:if test="${yellowPage.id>0}"><a href="${rootpath}/list.do"/>${title}列表</a></c:if>&gt; ${yellowPage.id==0 ? '新建' : '更新'}${title}</span></div>
		<div class="hd-bar">
			<input value="xxxxx" type="button" class="l-button" onClick="">
			<input value="xxxxx" type="button" class="l-button" onClick="">
		</div>
	</div>

	<div class="pnl-bd">
		<div id="errorLabelContainer"> <form:errors path="*"/>${error.param.wrong}</div>
		<input type="hidden" name="id" id="id" value="${yellowPage.id}"/>

		<fieldset class="field" id="baseField">
			<legend class="toggleBar">基本信息</legend>
			<div class="field-bd">
				<table class="tblWrap">
					<tr>
						<th><span class="required">*</span><font style="font-weight:bold;">企业名称：</font></th>
						<td><input type="text" id="name" maxlength="50" name="name" ligerui="width:300" value="${not empty yellowPage.name ? yellowPage.name.replaceAll('\"', '&quot;') : '无'}" validate="{required:true,minlength:0,maxlength:100}"/></td>
						<td id="S_nameControl">（设置简称）</td>
					</tr>
					<tr id="S_nameShort" style="display:none">
						<th><span class="required"></span>简称：</th>
						<td>
							<input type="text" name="nameShort" id="nameShort" value="${yellowPage.nameShort}" ligerui="width:300"/>
						</td>
					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">主营业务：</font></th>
						<td>
							<input type="text" name="mainProduct" id="mainProduct" value="${yellowPage.mainProduct}" ligerui="width:300"/>
						</td>
						<td>（以，隔开）</td>
					</tr>
                    <tr>
                        <th><span class="required"></span><font style="font-weight:bold;">地图坐标：</font></th>
                        <td>
                            <input type="text" name="position" id="position" value="${yellowPage.position}" ligerui="width:300"/>
                        </td>
						<td> <a target="_blank" href="http://api.map.baidu.com/lbsapi/getpoint/index.html"><font style="color: blue">（坐标查询）</font></a> </td>
                    </tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">首 图：</font></th>
						<td>
							<input type="text" name="firstPicUrl" id="firstPicUrl" value="${yellowPage.firstPicUrl}" ligerui="width:300"/>
						</td>
						<td>
							<img src="http://static.21cnimg.com/img/icons/silkicons/add.png" title="添加" alt="添加" style="cursor: pointer;"
								 onclick="f_select({'selectType':'/jsp/admin/resource/picture/uploads.jsp?multi=0&noConfirm=1','dialogWidth':'700','dialogHeight':'500','callback':'setFirstPicUrl'})"/>
						</td>
					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">地 区：</font></th>
						<td id="quickAreaSearch">
							<span class="quickSearch <c:if test="${yellowPage.areaId==701}">point</c:if>" name="areaId" value="701" onclick="setDefaultValue(701)">增城</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==692}">point</c:if>" name="areaId" value="692" onclick="setDefaultValue(692)">天河</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==693}">point</c:if>" name="areaId" value="693" onclick="setDefaultValue(693)">南沙</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==694}">point</c:if>" name="areaId" value="694" onclick="setDefaultValue(694)">白云</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==695}">point</c:if>" name="areaId" value="695" onclick="setDefaultValue(695)">海珠</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==703}">point</c:if>" name="areaId" value="703" onclick="setDefaultValue(703)">萝岗</span>|<br/>
							<span class="quickSearch <c:if test="${yellowPage.areaId==696}">point</c:if>" name="areaId" value="696" onclick="setDefaultValue(696)">荔湾</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==697}">point</c:if>" name="areaId" value="697" onclick="setDefaultValue(697)">越秀</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==698}">point</c:if>" name="areaId" value="698" onclick="setDefaultValue(698)">黄埔</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==699}">point</c:if>" name="areaId" value="699" onclick="setDefaultValue(699)">番禺</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==700}">point</c:if>" name="areaId" value="700" onclick="setDefaultValue(700)">花都</span>|
							<span class="quickSearch <c:if test="${yellowPage.areaId==702}">point</c:if>" name="areaId" value="702" onclick="setDefaultValue(702)">从化</span>|
							<input type="hidden" name="areaId" id="areaId" value="${yellowPage.areaId}">
						</td>

                        <th><span class="required"></span><font style="font-weight:bold;">类型：</font></th>
                        <td>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox" value="1" name="cateId" <c:if test="${fn:contains(yellowPage.cateIdList,'1')}">checked="checked"</c:if>">维修 &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox" value="2" name="cateId" <c:if test="${fn:contains(yellowPage.cateIdList,'2')}">checked="checked"</c:if>">装饰 &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox" value="3" name="cateId" <c:if test="${fn:contains(yellowPage.cateIdList,'3')}">checked="checked"</c:if>">美容 &nbsp;&nbsp;&nbsp;&nbsp;
                        </td>
					</tr>
				</table>
			</div>
		</fieldset>

		<!--=============================联系方式==========================-->
		<fieldset class="field" id="contactField">
			<legend class="toggleBar">联系方式</legend>
			<div class="field-bd">
				<table class="tblWrap">
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">公司地址：</font></th>
						<td><input type="text" id="address" maxlength="50" name="address" ligerui="width:300" value="${yellowPage.address}" validate="{required:true,minlength:0,maxlength:100}"/></td>
						<th><span class="required"></span><font style="font-weight:bold;">主页链接：</font></th>
						<td><input type="text" name="mainUrl" id="mainUrl" value="${yellowPage.mainUrl}" ligerui="width:300"/></td>
					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">固定电话：</font></th>
						<td><input type="text" name="linePhone" id="linePhone" value="${yellowPage.linePhone}" ligerui="width:300"/></td>
						<th><span class="required"></span><font style="font-weight:bold;">手机电话：</font></th>
						<td><input type="text" name="telPhone" id="telPhone" value="${yellowPage.telPhone}" ligerui="width:300"/></td>
					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">电子邮件：</font></th>
						<td><input type="text" name="email" id="email" value="${yellowPage.email}" ligerui="width:300"/></td>
						<th><span class="required"></span><font style="font-weight:bold;">邮政编码：</font></th>
						<td><input type="text" name="postCode" id="postCode" value="${yellowPage.postCode}" ligerui="width:300"/></td>

					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">负责人：</font></th>
						<td><input type="text" name="contactMan" id="contactMan" value="${yellowPage.contactMan}" ligerui="width:300"/></td>
						<th><span class="required"></span><font style="font-weight:bold;">传真号码：</font></th>
						<td><input type="text" name="faxCode" id="faxCode" value="${yellowPage.faxCode}" ligerui="width:300"/></td>
					</tr>
					<tr>
						<th><span class="required"></span><font style="font-weight:bold;">QQ：</font></th>
						<td><input type="text" name="qq" id="qq" value="${yellowPage.qq}" ligerui="width:300"/></td>
						<th><span class="required"></span><font style="font-weight:bold;">微信二维码：</font></th>
						<td><input type="text" name="wxinQrCode" id="wxinQrCode" value="${yellowPage.wxinQrCode}" ligerui="width:300"/></td>
						<td>
							<img src="http://static.21cnimg.com/img/icons/silkicons/add.png" title="添加" alt="添加" style="cursor: pointer;"
								 onclick="f_select({'selectType':'/jsp/admin/resource/picture/uploads.jsp?multi=0&noConfirm=1','dialogWidth':'700','dialogHeight':'500','callback':'setWxinQrCode'})"/>
						</td>
					</tr>
				</table>
			</div>
		</fieldset>

        <!--=============================文章组图==========================-->
        <fieldset class="field" id="pictureField">
            <legend class="toggleBar">
                黄页组图
                <img src="http://static.21cnimg.com/img/icons/silkicons/add.png" title="添加" alt="添加" style="cursor: pointer;"
                     onclick="f_select({'selectType':'/jsp/admin/resource/picture/uploads.jsp?multi=1&noConfirm=1','dialogWidth':'700','dialogHeight':'500','callback':'setThumbPicUrl'})"/>
            </legend>
            <div class="field-bd">
                <table class="tblWrap">
                    <c:if test="${empty yellowPage.yellowPagePictureList}">
                        <tr id="thumbImgBox"></tr>
                    </c:if>
                    <tr id="thumbImgBox">
                        <c:forEach var="thumbPicture" items="${yellowPage.yellowPagePictureList}" varStatus="var">
                            <td style="padding-right: 10px;">
                                <img src="${fn:replace(thumbPicture.picUrl,'/o/','/s/')}"  width="120" height="90" alt="" title="" />
                                <p>
                                    <input type="checkbox" name="thumbPicUrl" value="${thumbPicture.picUrl}" checked="checked"/>
                                </p>
                            </td>
                        </c:forEach>
                    </tr>
                </table>
            </div>
        </fieldset>

		<!--=============================文章正文==========================-->
		<fieldset class="field" id="introduceField">
			<legend class="toggleBar">企业简介</legend>
			<div class="field-bd">
				<table class="tblWrap" style="width:100%">
					<tr>
						<td><textarea id="J_CKEditor" name="introduce" rows="10" cols="80">${yellowPage.introduce}</textarea></td>
					</tr>
					<tr>
						<td colspan="2">
							<table class="tblWrap">
								<tr>
									<td style="display:none;"><input type="checkbox" checked="true" name="localPic" id="localPic">远程图片本地化</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</fieldset>

	</div>

	<div class="pnl-ft">
		<input value="提交" type="button" class="l-button" onClick="javascript:submitForm();">
		<input value="取消" type="button" class="l-button" onClick="javascript:top.tab.removeTabItem(top.tab.getSelectedTabItemID());" >
	</div>
</div>

</form:form>

<div style="display:none;"><iframe src="${STATIC_HOST}/jsp/admin/resource/picture/imgFetch.jsp?status=1" id="imgFetchIframeRegion"></iframe></div>

<script type="text/javascript" >
	var editor = CKEDITOR.replace( 'J_CKEditor', {});
	var mainform = $("#mainform");
	mainform.ligerForm();

	jQuery("#S_nameControl").click(function(){jQuery("#S_nameShort").toggle();});

	function setDefaultValue(id){
		jQuery("#quickAreaSearch span[value="+id+"]").addClass("point");
		jQuery("#quickAreaSearch span[value="+id+"]").siblings().removeClass("point");
		jQuery("#areaId").val(id);
	}

	function submitForm() {
		document.mainform.submit();
	}

    function setThumbPicUrl(jsonData) {
        var data= jQuery.parseJSON(jsonData);
        var html = "";
        for(var i=0 ; i< data.length; i++){
            var title = data[i].title;
            var src = data[i].url;
            src = src.replace("/o/","/s/");
            html = html+'<td style="padding: 20px;">'+
                    '<img width="120" height="90" title="'+title+'" alt="'+title+'" src="'+src+'">'+
                    '<p><input type="checkbox" value="'+src+'" name="thumbPicUrl" id="thumbPicUrl"></p>'+
                    '</td>';
        }
        jQuery("#thumbImgBox").append(html);
    }

	function setFirstPicUrl(jsonData) {
		var data= jQuery.parseJSON(jsonData);
		var html = "";
		for(var i=0 ; i< data.length; i++){
			var title = data[i].title;
			var src = data[i].url;
			jQuery("#firstPicUrl").val(src);
		}
	}

	function setWxinQrCode(jsonData) {
		var data= jQuery.parseJSON(jsonData);
		var html = "";
		for(var i=0 ; i< data.length; i++){
			var title = data[i].title;
			var src = data[i].url;
			jQuery("#wxinQrCode").val(src);
		}
	}
</script>
<div id="scrolltop">返回顶部</div>
<%@ include file="/jsp/inc/footer.jsp"%>
</body>
</html>